<?php

declare(strict_types=1);

namespace Plugin\Attractions\HaiKang\Model;

use Hyperf\DbConnection\Model\Model as MineModel;

/**
 * @property int $id 主键
 * @property int $device_id device表ID
 * @property string $hk_device_id 海康设备id
 * @property string $device_model 设备型号
 * @property string $device_name 设备名称
 * @property string $device_serial 设备序列号
 * @property int $device_status 设备状态 0：离线 1：在线
 * @property string $group_id 海康设备分组id
 * @property int $is_encrypt 设备加密状态：0-关闭，1-开启
 * @property string $device_version 设备固件版本号
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class HkDevice extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'hk_device';

    protected string $keyType = 'string';

    protected string $primaryKey = 'device_id';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['device_id', 'device_model', 'device_name', 'device_serial', 'device_status', 'group_id', 'is_encrypt', 'device_version', 'defence', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['device_status' => 'integer', 'is_encrypt' => 'integer', 'defence' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function channel()
    {
        return $this->hasOne(HkDeviceChannel::class, 'device_serial', 'device_serial');
    } 
}
